﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace GPMS.Web.Controllers
{
    using GPMS.Model;
    /// <summary>
    /// 主页控制器
    /// </summary>
    public class HomeController : BaseController
    {
        //
        // GET: /Home/

        public ActionResult Index()
        {

            return View(); 
        }

        public ActionResult SelectionStatus()
        {
            Setting setting=GPMS.BLL.SettingHelper.Get(gpmsDb);
            var list = gpmsDb.Specialties.Select(s => new SelectionStatus()
                  {
                      specialty = s,
                      Confirm = s.Users.Count(u => u.GPSelections.Any(gps => gps.IsConfirm)),
                      Total = s.Users.Count(u => u.Roles.Any(r => r.RoleID == setting.StudentRole))
                  }).ToList();
            list.ForEach(i =>
                i.Selectable = gpmsDb
                .GraduationProjects
                .Count(g => g.Guider.SpecialtyID == i.specialty.SpecialtyID && g.Maxman>g.GPSelections.Count() && g.Audit)
                );
            return View(list);
        }

       
    }
}
